<?php
class Zendvn_View_Helper_BestView extends Zend_View_Helper_Abstract{
	
	public function bestView(){
		
		$html='<table width="184" border="0" cellpadding="0" cellspacing="0" id="table">
		  <tr>
		    <td><img src="'.$this->view->imgUrl.'/topposts.jpg" width="183" height="38" /></td>
		  </tr>
		  <tr>
		 	<td id="infotable">';
		    
				foreach ($this->getBestView() as  $value) {
			
				    $html.='<table width="100%" border="0" cellspacing="0" cellpadding="2"  >
				    
				      <tr>
				        <td colspan="2">
				        <a href="'.$this->view->url(array("controller"=>"posts","action"=>"view","id"=>$value['id']),null,true).'">'.
				    nl2br(substr( strip_tags( $value['Title']), 0 , 30)).'</a></td>
				        </tr>
				    </table>';    
			    }
			$html.=' </td>
		</tr>
	</table><br />';
	   return $html;
	}
	
	public function getBestView(){
		$post = new Default_Model_DbTable_Posts();
		return $post->getPostsView(); //Xem getPostsView trong Model Post() lay ra 4 Posts co so view lon nhat
	}

}